package com.icity.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.icity.common.Result;
import com.icity.entity.Application;
import com.icity.entity.EquipmentDistribution;
import com.icity.entity.PartnerMsg;
import com.icity.entity.PermissionsEntity;
import com.icity.entity.RegisteredUse;
import com.icity.entity.ResourceDistribution;
import com.icity.entity.StatisticalSummary;
import com.icity.entity.journalBookReadBorrow;
import com.icity.entity.journalBookStatistical;
import com.icity.service.StatisticalSummaryService;
import com.icity.util.PermissionsUtil;

@RestController
@RequestMapping(value="/admin/JournalBookStatistical")
public class journalBookStatisticalController {
  @Autowired
  private StatisticalSummaryService statisticalSummaryService;
  /**
   * 期刊或者图书数量(前三个icon)
   * @return
   */
  @RequestMapping(value="/getJournalBookCount")
 // @PostMapping(value="/getCount")
  @ResponseBody
  public Result getCount(HttpServletRequest request) {
	  Result result=new Result();
	 try {
		 //获取资源类型
		 int resource_type=Integer.valueOf(request.getParameter("resource_type"));
		 //获取应用唯一标识
		 String application_unique_code=request.getParameter("application_unique_code");
		 //获取合伙人id
		 String partner_id=request.getParameter("partner_id");
			//获取客户端类型
			int type=Integer.valueOf(request.getParameter("type"));
		 Map<Object, Object> map=new HashMap<>();
		 map.put(type, "type");
		 map.put(application_unique_code, "application_unique_code");
		 map.put(partner_id, "partner_id");
		 map.put(resource_type, "resource_type");
		 List<journalBookStatistical> list = statisticalSummaryService.getAlljournalBook(map);;
			if(list != null && list.size() > 0) {
				result.setMessage("获取成功");
				result.setCode("1");
				result.setData(list);
			}else {
				result.setCode("-1");
				result.setData(new ArrayList<>());
				result.setMessage("暂无数据");
			}
	} catch (Exception e) {
		result=new Result();
		result.setCode("-1");
		result.setMessage("获取数据异常");
	}
	  
	  return result;
  }
  
  
  
  /**
   * 图书/期刊借阅量排行前十()
   * @return
   */
  @RequestMapping(value="/getJournalBookreadbroow")
 // @PostMapping(value="/getCount")
  @ResponseBody
  public Result getJournalBookreadbroow(HttpServletRequest request) {
	  Result result=new Result();
	 try {
		 //获取资源类型
		 int resource_type=Integer.valueOf(request.getParameter("resource_type"));
		 //获取应用唯一标识
		 String application_unique_code=request.getParameter("application_unique_code");
		 //获取合伙人id
		 String partner_id=request.getParameter("partner_id");
			//获取客户端类型
			int type=Integer.valueOf(request.getParameter("type"));
		 Map<Object, Object> map=new HashMap<>();
		 map.put(type, "type");
		 map.put(application_unique_code, "application_unique_code");
		 map.put(partner_id, "partner_id");
		 map.put(resource_type, "resource_type");
		 List<journalBookReadBorrow> list = statisticalSummaryService.getjournalBookreadbroow(map);;
			if(list != null && list.size() > 0) {
				result.setMessage("获取成功");
				result.setCode("1");
				result.setData(list);
			}else {
				result.setCode("-1");
				result.setData(new ArrayList<>());
				result.setMessage("暂无数据");
			}
	} catch (Exception e) {
		result=new Result();
		result.setCode("-1");
		result.setMessage("获取数据异常");
	}
	  
	  return result;
  }
 
  
  
  /**
   * 图书/期刊阅读量（下载量）排行前十()
   * @return
   */
  @RequestMapping(value="/getJournalBookreadbroows")
 // @PostMapping(value="/getCount")
  @ResponseBody
  public Result getJournalBookdownbroow(HttpServletRequest request) {
	  Result result=new Result();
	 try {
		 //获取资源类型
		 int resource_type=Integer.valueOf(request.getParameter("resource_type"));
		 //获取应用唯一标识
		 String application_unique_code=request.getParameter("application_unique_code");
		 //获取合伙人id
		 String partner_id=request.getParameter("partner_id");
			//获取客户端类型
			int type=Integer.valueOf(request.getParameter("type"));
		 Map<Object, Object> map=new HashMap<>();
		 map.put(type, "type");
		 map.put(application_unique_code, "application_unique_code");
		 map.put(partner_id, "partner_id");
		 map.put(resource_type, "resource_type");
		 List<journalBookReadBorrow> list = statisticalSummaryService.getjournalBookdownreadbroow(map);;
			if(list != null && list.size() > 0) {
				result.setMessage("获取成功");
				result.setCode("1");
				result.setData(list);
			}else {
				result.setCode("-1");
				result.setData(new ArrayList<>());
				result.setMessage("暂无数据");
			}
	} catch (Exception e) {
		result=new Result();
		result.setCode("-1");
		result.setMessage("获取数据异常");
	}
	  
	  return result;
  }
 
}
